import * as fs from "fs";
import { FormatCodes } from "../format";
import { GaRegExp, getRule } from '../rule';

const exportExecuteRule = getRule("exportExecuteRule");

const rule = new GaRegExp(["^", exportExecuteRule, "$"]);

console.log(rule.RegExpList.origin);
console.log(rule.RegExpList.list);

const code = `
const valueA: Number = valueB ;

const num: Number = 123456.97 ;

const str: String = "123456" + "987" ;

const the_type: String = 100.toString(16) ;

const obj: Object = ( (func1) () . aaa ) . bbb [0] [0] [0] [0] [0] [0] [0] () + 999 ;

num += ( !7 + ( -7  +\n\r\t ~7 + 45 & 32 >> 89 ) + new 24) * -num ;

new aaa("123")[0][0][0][0];

const funcA = func(){};

func funcB<A,B,C> (a:A, b:B, c:C, d) {
	const a = 100 ;
	var b = 200 ;
	bind c = a + b ;
	return 100;
	return "100" + "200" ? 100 : 200 ;
	return func(){}();
	return new aaa();
}

@iii
@jjj()
@kkk(100,200)
class classa<T,F,G>{

	public const a = 100;

	@deprecated()
	private const b = new Array();

	protected class child{
	}

}

struct aaa<K,S,H> {
	id: Array<Number>;
	name: String;
}

interface bbb<I,N,T> {
	id: Number;
	name: Array<String>;
}

const ccc: Array<Number,String,Array<String>> = [100,200,300];

const ddd = { a:100, b:200 };

while (a>200) {
	console.log("大于200");
	var a = 100;
}

do {
	console.log("do循环");
	var a = 100;
} while (a>200)

for (var a=100; a<500; a++) {
	console.log("for循环");
	console.log("for循环打印");
}

if (a>100) {
	console.log("a大于100", a, 100);
	console.log();
}
else if (a>50) {
	console.log();
	console.log();
}
else if (a>30) {
	console.log();
	console.log();
}
else {
	console.log();
	console.log();
}

try {
	console.log();
	console.log();
}
catch(Exception){
	console.log();
	console.log();
}
catch(IoException){
	console.log();
	console.log();
}
finally{
	console.log();
	console.log();
}

export const aaa = 100;

type a<T> = "aaa" | 100 | true | { a: String } & { b: Number } | Array<a> | [String, Number, "aaa"|"bbb"] | T;

const { a:A, b } = { a:100, b:200 };

const [a1, a2, a3] = [100, 200, 300];

import "./aaa";
import aaa from "./aaa";
import aaa as bbb from "./aaa";
import aaa, { aaa } from "./aaa";
import aaa as bbb, { aaa as bbb } from "./aaa";
import aaa, { aaa, aaa } from "./aaa";
import aaa as bbb, { aaa as bbb, aaa as bbb } from "./aaa";
import { aaa } from "./aaa";
import { aaa as bbb } from "./aaa";
import { aaa, aaa } from "./aaa";
import { aaa as bbb, aaa as bbb } from "./aaa";

const a = ++a+++a;

`;

const jsonStr = rule.MatchFormat(code, undefined, 2);
fs.writeFileSync(__dirname + "/test.json", jsonStr);

const result = rule.Match(code) as any | undefined;
if (result === undefined) {
	console.log("match error");
} else {
	console.log(FormatCodes(result));
}

debugger;
